package com.hjwoo.app.ui;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.hjwoo.app.R;

public class CenterAlertDialog extends Dialog implements OnClickListener
{
    private Button mOK;
    private Button mCancel;
    private String titleStr;
    private String contentStr;

    public CenterAlertDialog(Context context, String titleStr, String contentStr)
    {
        super(context);
        this.titleStr = titleStr;
        this.contentStr = contentStr;
    }

    public CenterAlertDialog(Context context, int theme, String titleStr, String contentStr)
    {
        super(context, theme);
        this.titleStr = titleStr;
        this.contentStr = contentStr;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.alertdialog_center);
        Window win = getWindow();
//		win.getDecorView().setPadding(0, 0, 0, 0);
        win.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams lp = win.getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
//		lp.height = wm.getDefaultDisplay().getHeight()/2;
        win.setAttributes(lp);
        TextView title   = (TextView) this.findViewById(R.id.alertdialog_center_title);
        TextView content = (TextView) this.findViewById(R.id.alertdialog_center_content);
        title.setText(titleStr);
        content.setText(contentStr);
        mOK = (Button) this.findViewById(R.id.alertdialog_center_ok);
        mCancel = (Button) this.findViewById(R.id.alertdialog_center_cancel);
        mOK.setOnClickListener(this);
        mCancel.setOnClickListener(this);
    }
    @Override
    public void onClick(View v)
    {
        switch (v.getId())
        {
        case R.id.alertdialog_center_ok:
            doOK();
            break;
        case R.id.alertdialog_center_cancel:
            dismiss();
            break;
        }
    }


    public void doOK()
    {

    }
}
